Basic encryption
Theenc_value function encrypts a single 64-bit unsigned integer:
Function signature
Frominclude/pvac/ops/encrypt.hpp:740-742:
enc_value is a wrapper around enc_value_depth with depth hint 0, suitable for fresh encryptions.Basic decryption
Thedec_value function decrypts a ciphertext back to a field element:
Function signature
Frominclude/pvac/ops/decrypt.hpp:77-79:
Encryption with depth hints
For computations at specific circuit depths, useenc_value_depth to preallocate noise budget:
include/pvac/ops/encrypt.hpp:732-738:
When to use depth hints
Ciphertext structure
Frominclude/pvac/core/types.hpp:116-121:
Components explained
std::vector<Layer> LRepresents the computation graph layers. Base layers contain randomness seeds, product layers encode multiplications.
std::vector<Edge> EEdges in the computation graph. Each edge has:
layer_id: Which layer it belongs toidx: Index in the multiplicative group (0 to B-1)ch: Sign channel (SGN_P or SGN_M)w: Weight vector (field elements)s: LPN noise bits
std::vector<Fp> c0Constant term added to the encrypted value.
size_t slotsNumber of values packed in this ciphertext (default 1).
Multi-slot encryption
Encrypt vectors of values usingenc_values:
include/pvac/ops/encrypt.hpp:753-756:
Multi-slot encryption packs multiple values into a single ciphertext, enabling SIMD-style operations.
Decryption algorithm
Thedec_values function implements the full decryption procedure:
1
Compute layer randomness
For each layer, compute R using PRF with the layer seed
2
Invert randomness
Compute R^(-1) for each layer to unmask edges
3
Accumulate edges
Sum all edges: acc = Σ sign(e) · w · g^idx · R^(-1)
4
Add constant term
Add c0 to the accumulator
include/pvac/ops/decrypt.hpp:46-75:
Performance characteristics
From benchmark data:Comparison with other schemes
Testing correctness
Fromexamples/basic_usage.cpp:59-63:
Edge cases
Encryption randomness
Every encryption is randomized. Two encryptions of the same value produce different ciphertexts:examples/basic_usage.cpp:216-221:
Advanced: Field element encryption
For direct field element encryption, useenc_fp_depth:
Next steps
Arithmetic operations
Perform ct_add, ct_mul, ct_sub on ciphertexts
Text encryption
Encrypt and decrypt strings